********************************************************************************
* 		Make main_extended.dta for registration analysis through 2016
********************************************************************************

use elec_yr cb yr0 cb_shoot cb_sht_count sample_main using ///
	../data_intermediate/shootings_cb_by_elec.dta,clear
merge 1:1 elec_yr cb using ../data_intermediate/reg_2002_2016.dta, assert(3) nogen
keep if sample_main==1
xtile pop_dec = all_c02, n(10)
gen tau_extended = (elec_yr - yr0)/2 if yr0!=.
replace tau_extended = . if yr0==2002
gen tau_extended2 = tau_extended
replace tau_extended2 = floor(tau_extended2/2) if tau_extended2>=0
gen treat = tau_extended!=.
tab tau_extended elec_yr,m
save ../data/main_extended.dta,replace 
